package com.ct.utils;

import org.apache.commons.lang3.StringUtils;

public class DefaultUtil {

    public static String stringDefault(String source) {
        return StringUtils.defaultIfEmpty(source, StringUtils.EMPTY);
    }

    public static String stringDefault(String source,String defaultVal) {
        return StringUtils.defaultIfEmpty(source, defaultVal);
    }

    public static String stringDefault(String source,String firstDefaultVal,String secondDefaultVal) {
        String value = StringUtils.defaultIfEmpty(source, firstDefaultVal);
        return StringUtils.defaultIfEmpty(value, secondDefaultVal);
    }


    public static Long longDefault(Long source,Long defaultVal) {
        return source != null ? source : defaultVal;
    }



    public static Integer intDefault(Integer source,Integer defaultVal) {
        return source != null ? source : defaultVal;
    }

    public static Integer intDefault(Integer source,Integer firstDefaultVal,Integer secondDefaultVal) {
        Integer value = source != null ? source : firstDefaultVal;
        value = value != null ? value : secondDefaultVal;
        return value;
    }

}
